<?php
/*
 * Plugin pozwalający na wykorzystanie osobnego errorControllera dla kazdego modułu.
 */
class My_Plugin_ErrorControllerSelector extends Zend_Controller_Plugin_Abstract
{
	public function routeShutdown(Zend_Controller_Request_Abstract $oRequest)
	{
		$oFront = Zend_Controller_Front::getInstance();
 
		if( !( $oFront->getPlugin('Zend_Controller_Plugin_ErrorHandler') instanceOf Zend_Controller_Plugin_ErrorHandler ) )
			return;
 
		$oError = $oFront->getPlugin('Zend_Controller_Plugin_ErrorHandler');
 
		$oTestRequest = new Zend_Controller_Request_HTTP();
		$oTestRequest->setModuleName($oRequest->getModuleName())
		            ->setControllerName($oError->getErrorHandlerController())
		            ->setActionName($oError->getErrorHandlerAction());
 
		if( $oFront->getDispatcher()->isDispatchable($oTestRequest) )
		{
			$oError->setErrorHandlerModule($oRequest->getModuleName());
		}
	}
}
?>